package com.race.entities.po;

import com.race.entities.po.Base.AbstractEntity;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;

import javax.persistence.*;
import java.io.Serializable;
import java.util.List;
import java.util.Set;

/**
 * @ClaissName: user
 * @Description: 用户PO对象
 * @Author: xcheng
 */
@DynamicInsert
@DynamicUpdate
@Getter
@Setter
@Entity
@Table(name = "users")
public class User extends AbstractEntity {
    /**
     * 用户名
     * */
    private String username;

    /**
     * 用户密码
     * */
    private String password;

    /**
     * 昵称
     */
    private String name;

    /**
     * 盐值
     */
    private String salt;

    /**
     * 用户状态 0：创建用户
     *          1: 正常
     *          2：用户被锁定
     */
    @Column(nullable = false,columnDefinition = "int default 1")
    private byte state;

    /**
     * 用户----角色
     */
    @ManyToMany(fetch = FetchType.EAGER)
    @JoinTable(joinColumns = {@JoinColumn(name = "uid")},
            inverseJoinColumns = {@JoinColumn(name = "rid")} )
    private Set<Role> roles;
}
